<?php


namespace backend\controllers;
use yii\base\Request;
use Yii;
use yii\web\Controller;
use backend\models\Order;
use backend\models\Total;

class TotalController extends Controller
{
    /**
     * 当天销售量及当天销售额
     */
    public function actionTodaysell()
    {
        //$data=Order::find();
        $request = Yii::$app->request;

        return $this->render('todaysell');
    }
    /*
     * 获取今日销售总额
     *
     * */
    public function actionGet_today_data(){
        $today=date('Y-m-d',time());
        $request=Yii::$app->request;
        $date=empty($request->get('date'))?$today:$request->get('date');
        $arr=Total::getSql($date,null);
        echo json_encode($arr);
    }

    /**
     * 销售概况
     */
    public function actionSell(){
        return $this->render('monthsell');
    }
    /*
     * 获取当月销售量
     * */
    public function actionGet_month_data(){
        $tomonth=date('Y-m',time());
        $request=Yii::$app->request;
        $date=empty($request->get('date'))?$tomonth:$request->get('date');

        $arr=Total::getSql($date,'month');
        echo json_encode($arr);
    }
    /**
     * 会员排行
     */
    public function actionUserrank(){

    }
    /**
     *销售排行
     */
    public function actionSellrank(){
           return $this->render('sellrank');
    }
    /*
     * 获取销售排行数据
     * */
    public function actionGetsellrank(){
        $tomonth=date('Y-m',time());
        $request=Yii::$app->request;
        $date=empty($request->get('date'))?$tomonth:$request->get('date');
        $arr=Total::getSql($date,'rank');
        echo json_encode($arr);
    }
    /**
     *Top100-秒杀次数前100名用户
     */
    public function actionTop(){
        return $this->render('top');
    }


    public function actionGetdata(){
        $arr=Total::get_top();
        echo json_encode($arr);
    }
}